package com.douhulu.bytedance.common.enums;

import com.google.common.collect.Maps;
import lombok.Getter;

import java.util.Map;

/**
 * <h2> 奕泽云 -  </h2>
 *
 * @Author: 奕泽云 - 曾庆雷
 * @Email: 75881401@qq.com
 * @Since: 2022-05-01 13:40
 * CopyRight：山西威斯汀文化传播有限公司
 */
@Getter
public enum ByteMaErrorMsgEnum {

    CODE_40001(40001, "参数错误"),
    ;

    private final int code;
    private final String msg;

    ByteMaErrorMsgEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    static final Map<Integer, String> valueMap = Maps.newHashMap();

    static {
        for (ByteMaErrorMsgEnum value : ByteMaErrorMsgEnum.values()) {
            valueMap.put(value.code, value.msg);
        }
    }

    /**
     * 通过错误代码查找其中文含义.
     */
    public static String findMsgByCode(int code) {
        return valueMap.getOrDefault(code, null);
    }
}
